package ro.gateway.aida.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;



/**
 * Created by IntelliJ IDEA.
 * User: xblue
 * Date: 28.06.2003
 * Time: 00:36:51
 * To change this template use Options | File Templates.
 * @deprecated
 */
public class OracleLiteTester
{
      public static void main( String[] args )
      {
            main2( args );
      }

      public static void main2( String[] args )
      {
            try
            {
                  Class.forName( "oracle.lite.poljdbc.POLJDBCDriver" );
//               Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
            }
            catch ( ClassNotFoundException e )
            {
                  e.printStackTrace();  //To change body of catch statement use Options | File Templates.
            }

            try
            {
                  String connection_string =
                        "jdbc:polite:gateway;" +
                        "DataDirectory=c:\\oracle\\ora90\\Mobile\\Sdk\\OLDB40;" +
                        "Database=gateway;IsolationLevel=SINGLE;" +
                        "USER;Autocommit=ON;" +
                        "CursorType=DYNAMIC";
                  Connection con = DriverManager.getConnection( connection_string,
                        "system", "lpdweb" );
                  Connection con1 = DriverManager.getConnection( connection_string,
                        "system", "lpdweb" );

                  Statement ps = con.createStatement();
                  ResultSet rs = ps.executeQuery( "SELECT id from x" );
//               ResultSet rs1 = ps.executeQuery( "SELECT sysdate from dual" );
                  while ( rs.next() )
                  {
                        System.out.println( rs.getLong( 1 ) );
                        System.out.flush();
                  }
//               if ( rs1.next() ) {
//                    Timestamp t = rs1.getTimestamp( 1 );
//                    System.out.println( "time: " + t );
//               }
                  rs.close();
//               rs1.close();
                  ps.close();


                  con.close();
                  con1.close();
            }
            catch ( SQLException e )
            {
                  e.printStackTrace();  //To change body of catch statement use Options | File Templates.
            }
      }

      public static void main1( String[] args )
      {
            try
            {
                  Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
            }
            catch ( ClassNotFoundException e )
            {
                  e.printStackTrace();  //To change body of catch statement use Options | File Templates.
            }

            try
            {
                  String connection_string =
                        "jdbc:odbc:gateway";

                  Connection con = DriverManager.getConnection( connection_string,
                        "system", "lpdweb" );
                  Connection con1 = DriverManager.getConnection( connection_string,
                        "system", "lpdweb" );

                  Statement ps = con.createStatement();
//               ResultSet rs = ps.executeQuery( "SELECT id from x" );
                  ResultSet rs1 = ps.executeQuery( "SELECT d from y" );
//               while ( rs.next() ) {
//                    System.out.println( rs.getLong( 1 ) );
//               }
                  if ( rs1.next() )
                  {
                        Timestamp t = rs1.getTimestamp( 1 );
                        System.out.println( "time: " + t );
                  }
//               rs.close();
                  rs1.close();
                  ps.close();


                  con.close();
                  con1.close();
            }
            catch ( SQLException e )
            {
                  e.printStackTrace();  //To change body of catch statement use Options | File Templates.
            }
      }
}
